package com.spsoft.vatoutinv;

import cn.hutool.core.convert.Convert;
import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

@EnableEncryptableProperties
@EnableFeignClients(basePackages = "com.spsoft.einvoicetodmz.*")
@SpringBootApplication(scanBasePackages = "com.spsoft.*")
@MapperScan("com.spsoft.*.mapper")
@Slf4j
public class VatoutinvApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(VatoutinvApplication.class);
    }
    public static void main(String[] args) throws Exception{
        ConfigurableApplicationContext application = SpringApplication.run(VatoutinvApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("local.server.port");
        String path = Convert.toStr(env.getProperty("server.servlet.context-path",""));
        log.info("\n----------------------------------------------------------\n\t" +
                "Application running! Access URLs:\n\t" +
                "Local: \t\thttp://localhost:" + port + path + "/\n\t" +
                "External: \thttp://" + ip + ":" + port + path + "/\n\t" +
                "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" +
                "----------------------------------------------------------");

    }

}
